/*
 * @(#) ActionType.java 2011-6-20
 *
 * Copyright (c) 2011, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.common.util;

/**
 * 固定编号
 * 
 * @author lilanfei
 * @version 1.0
 * @since 2011-6-20
 */
public class CodeBook {
	
	/**
	 * 角色
	 */
	public static enum ROLE {
		SADMIN(9, "超级管理员"),
		NADMIN(2, "普通管理员"),
		NUSER(1, "普通用户");
		Integer code;
		String name;
		ROLE(Integer code, String name) {
			this.code = code;
			this.name = name;
		}
		public Integer getCode() {
			return code;
		}
		public String getName() {
			return name;
		}
		
		public static ROLE valueOfCode(Integer code) {
			for (ROLE tmp : ROLE.values()) {
				if (tmp.code.equals(code)) {
					return tmp;
				}
			}
			return null;
		}
		// 是否是管理员
		public static boolean isAdmin(Integer code) {
			if (code != null
					&& (SADMIN.getCode().compareTo(code) == 0
							|| NADMIN.getCode().compareTo(code) == 0))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		// 是否是超级管理员
		public static boolean isSuperAdmin(Integer code) {
			if (code != null && SADMIN.getCode().compareTo(code) == 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
	
	/**
	 * 出勤状态
	 */
	public static enum ATTENDANCE_STATUS {
		CQ("1", "出勤"),
		SJ("2", "事假"),
		BJ("3", "病假"),
		NXJ("4", "年休假"),
		KG("5", "旷工"),
		JB("6", "加班");
		String code;
		String name;
		ATTENDANCE_STATUS(String code, String name) {
			this.code = code;
			this.name = name;
		}
		public String getCode() {
			return code;
		}
		public String getName() {
			return name;
		}
		
		public static ATTENDANCE_STATUS valueOfCode(String code) {
			for (ATTENDANCE_STATUS tmp : ATTENDANCE_STATUS.values()) {
				if (tmp.code.equals(code)) {
					return tmp;
				}
			}
			return null;
		}
	}
	
	/**
	 * 工作年限范围
	 */
	public static enum RANGE_TYPE {
		WITHIN(0, "以内"),
		OVER(1, "以上");
		Integer code;
		String name;
		RANGE_TYPE(Integer code, String name) {
			this.code = code;
			this.name = name;
		}
		public Integer getCode() {
			return code;
		}
		public String getName() {
			return name;
		}
		
		public static RANGE_TYPE valueOfCode(Integer code) {
			for (RANGE_TYPE tmp : RANGE_TYPE.values()) {
				if (tmp.code.equals(code)) {
					return tmp;
				}
			}
			return null;
		}
	}
	
	/**
	 * 分数是否为自动计算
	 */
	public static enum IS_AUTO {
		YES("1", "是"),
		NO("0", "否");
		String code;
		String name;
		IS_AUTO(String code, String name) {
			this.code = code;
			this.name = name;
		}
		public String getCode() {
			return code;
		}
		public String getName() {
			return name;
		}
		
		public static IS_AUTO valueOfCode(String code) {
			for (IS_AUTO tmp : IS_AUTO.values()) {
				if (tmp.code.equals(code)) {
					return tmp;
				}
			}
			return null;
		}
	}
	
	/**
	 * 规则分数是否基于总分数
	 */
	public static enum IS_BASE_TOTAL {
		YES("1", "是"),
		NO("0", "否");
		String code;
		String name;
		IS_BASE_TOTAL(String code, String name) {
			this.code = code;
			this.name = name;
		}
		public String getCode() {
			return code;
		}
		public String getName() {
			return name;
		}
		
		public static IS_BASE_TOTAL valueOfCode(String code) {
			for (IS_BASE_TOTAL tmp : IS_BASE_TOTAL.values()) {
				if (tmp.code.equals(code)) {
					return tmp;
				}
			}
			return null;
		}
	}

}
